var canConstruct = function(ransomNote, magazine) {
    let n=ransomNote.length,
        m=magazine.length;
    let map =new Map()
    for(let i=0;i<m;i++){
        if(map.has(magazine[i])){
            var count = map.get(magazine[i])
            map.set(magazine[i],++count)
        }else{
            map.set(magazine[i],1)
        }
    }
    for(let i=0;i<n;i++){
        if(map.has(ransomNote[i])){
            var count =map.get(ransomNote[i])
            if(count<1) return false
            map.set(ransomNote[i],--count)
        }else{
            return false
        }
    }
    return true
};
//console.log(canConstruct( "aa","aab"));